package org.sxp.common.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author shenxingping
 * @TODO 描述
 * @date 2022/04/07
 */
@Component
@Order(-110)
@Slf4j
public class XpContextClearFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        /**
         * 解决ThreadLocal 线程共享导致Hsaf上下文信息共享，用户信息混乱
         */
        XpContextHolder.setContext(null);
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {

    }
}
